﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OtherDevice
{
    public partial class Form_UVControl : Form_ControlBase
    {
        UVControlBase uv = null;
        public Form_UVControl()
        {
            InitializeComponent();
        }
        public override void FlushToDlg(object devicebase)
        {
            try
            {
                if (devicebase == null)
                    return;
                this.uv = devicebase as UVControlBase;
                this.Dock = DockStyle.Fill;
                this.Show();
            }
            catch (Exception)
            {

            }

        }

        private void btn_Set电功率_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Channal = Convert.ToInt32(cbb_UVChannal.Text);
                int n_Value = Convert.ToInt32(txt_UVPower.Text);
                uv.Function_Set电功率(n_Channal, n_Value);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btn_Read电功率_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Channal = Convert.ToInt32(cbb_UVChannal.Text);
                double d_Value= uv.Function_Get电功率(n_Channal);
                lbl_电功率值.Text = $"{d_Value}W";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_Read能量_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Channal = Convert.ToInt32(cbb_UVChannal.Text);
                double d_Value = uv.Function_Get光功率能量值(n_Channal);
                lbl_光功率能量值.Text = $"{d_Value}mW";

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
